<%@ page language="java" contentType="text/html; charset=UTF-8"
         import="java.util.*" pageEncoding="UTF-8" %>
<%@page language="java" import="db_tool.DBConnection" %>
<%@page language="java" import="java.sql.ResultSet" %>
<%@page language="java" import="java.sql.Statement" %>

<%@page language="java" import="com.opensymphony.xwork2.ActionContext" %>
<%
    String email = (String) session.getAttribute("email");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="edge"/>
    <meta name="author" content="Daliu"/>
    <meta name="keywords" content="长江上游珍稀特有鱼类保护信息管理系统、长江上游、珍稀特有鱼类、保护信息"/>
    <meta name="describe" content="长江上游珍稀特有鱼类保护信息管理系统"/>
    <title>长江上游珍稀特有鱼类保护信息管理系统</title>
    <link rel="icon" href="<%=path%>/bfish.ico"
          mce_href="<%=path%>/bfish.ico" type="image/x-icon">
    <link rel="shortcut icon" href="<%=path%>/bfish.ico"
          mce_href="<%=path%>/bfish.ico" type="image/x-icon">
    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
    <link type="text/css" href="css/partI.css" rel="stylesheet"/>
    <!-- 表单验证 -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/jquery.validate.min.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.3-min.js"></script>

    <script type="text/javascript">
        window.onload = function () {
            $(".phone-verification").hide()
            $(".phone-checkCode").hide()
            $(".email-verification").show()
            $(".email-checkCode").show()
            $("#emailNumber").val("<%=email%>");
        }

        //导航定位
        $(function () {
            //$(".nav li:eq(2) a:first").addClass("navCur")
            //验证手机 邮箱
            $(".verification").change(function () {
                var selectVal = $(this).find("option:selected").val();
                if (selectVal == "0") {
                    $(".phone-verification").hide()
                    $(".phone-checkCode").hide()
                    $(".email-verification").show()
                    $(".email-checkCode").show()
                }
                else if (selectVal == "1") {
                    $(".phone-verification").show()
                    $(".phone-checkCode").show()
                    $(".email-verification").hide()
                    $(".email-checkCode").hide()
                }
            })
        })
    </script>


</head>
<body class="background">

<div class="content">
    <div class="web-width">
        <div class="for-process">
            <div class="plist for-cur"></div>
            <div class="plist for-cur"></div>
            <div class="plist"></div>
            <div class="plist"></div>
            <div class="ptextbox">
                <div class="ptext for-cur"><em>1</em><br/><strong>填写账户名</strong></div>
                <div class="ptext for-cur"><em>2</em><br/><strong>验证身份</strong></div>
                <div class="ptext"><em>3</em><br/><strong>设置新密码</strong></div>
                <div class="ptext"><em>4</em><br/><strong>完成</strong></div>
            </div>
        </div><!--for-liucheng/-->
        <form class="forget-pwd">
            <dl>
                <dt>验证方式：</dt>
                <dd>
                    <select class="verification">
                        <option value="0">邮箱验证</option>
                        <%--<option value="1">手机验证</option>--%>
                    </select>
                </dd>
                <div class="clears"></div>
            </dl>
            <dl class="phone-verification">
                <dt>手机号：</dt>
                <dd><input type="text" id="phoneNumber" readonly/></dd>
                <div class="clears"></div>
            </dl>
            <dl class="email-verification">
                <dt>邮箱号：</dt>
                <dd><input type="text" id="emailNumber" readonly/></dd>
                <div class="clears"></div>
            </dl>
            <dl class="phone-checkCode">
                <dt>手机校验码：</dt>
                <dd><input type="text"/>
                    <button>获取短信验证码</button>
                </dd>
                <div class="clears"></div>
            </dl>
            <dl class="email-checkCode">
                <dt>邮箱校验码：</dt>
                <dd><input id="emailCode" type="text" maxlength="6"
                           onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)"
                           onblur="this.v();"/>
                    <button id="getEmailCode">获取邮箱验证码</button>
                    <div id="sendTip"></div>
                </dd>
                <div class="clears"></div>
            </dl>
            <div class="submit"><input id="submit" type="submit" value="提交"/></div>
        </form><!--forget-pwd/-->

        <script type="text/javascript">
            var countdown = 60;
            var selectVal = $(".verification").find("option:selected").val();
            //点击提交按钮以后,通过selectVal判断验证方式
            $().ready(function () {
                $("#submit").click(function () {

                    if (selectVal == 0) {
                        var code = $("#emailCode").val();
                        emailValidate(code);
                    } else if (selectVal == 1) {
                        //手机验证尚未实现
                    }
                })
            })
            //发送验证码
            $(function () {
                $("#getEmailCode").click(function () {
                    var email = $("#emailNumber").val();
                    var codeArea = this;
                    $.ajax({
                        url: "sendCode.action",
                        type: "POST",
                        data: {
                            "Email": email,
                        },
                        async: false,
                        success: function (result) {
                            if (result == "true") {
                                alert("发送成功");
                                //setTime(codeArea);
                            } else {
                                alert("验证码发送失败,请检查网络连接");
                            }
                        }
                    });
                })
            });
            //获取邮箱验证码
            function setTime(obj) {
                if (countdown == 0) {
                    obj.removeAttribute("disabled");
                    obj.innerHTML = "获取邮箱验证码";
                    countdown = 60;
                    return;
                } else {
                    obj.setAttribute("disabled", true);
                    obj.innerHTML = "重新发送(" + countdown + ")";
                    countdown--;
                }
                //设置setTime每秒执行一次
                setTimeout(function () {
                        setTime(obj)
                    }
                    , 1000)
            }
            //检验验证码是否匹配,若匹配进入下一阶段
            function emailValidate(code) {
                if (code == "<%=session.getAttribute("code")%>") {
                    <% session.setAttribute("code","======");%>
                    window.location.href = "findPasswordPartIII.jsp";
                    window.event.returnValue = false;
                } else {
                    alert("验证码输入错误");
                }
            }

        </script>

    </div><!--web-width/-->
</div><!--content/-->

</body>
</html>